package com.yawn.zerodefect.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author yawn
 * @date 2018-03-13 12:32
 */
public class UtilTest {

    public static void main(String[] args) throws InterruptedException {

        /// 线程池测试
//        ThreadUtil.poolExecute(() -> System.out.println("...runnable..."));
////
////        String result = ThreadUtil.poolExecute(() -> "...callable...");
////        System.out.println(result);


        ExecutorService pool = Executors.newCachedThreadPool();
        for (int i = 0; i < 225; i++) {
            pool.submit(() -> {
                System.out.println(Thread.currentThread().getName() + "\t" + pool.toString());
            });
        }

//        System.out.println("----sleep----");
//        Thread.sleep(3000L);

//        ExecutorService pool2 = Executors.newCachedThreadPool();
//        for (int i = 0; i < 10; i++) {
//            pool2.submit(() -> {
//                System.out.println(Thread.currentThread().getName() + pool2.toString());
//            });
//        }
//        pool.shutdown();
    }
}